package com.zjuee.web.ledger.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zjuee.base.dto.common.login.LoginDto;
import com.zjuee.base.dto.common.plan.PlanHDeviceDto;
import com.zjuee.service.PlanHDeviceService;
import com.zjuee.service.PlanService;
import com.zjuee.base.model.common.plan.PlanHDevice;
import com.zjuee.web.ledger.mapper.PlanHDeviceMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ding jinli
 * @since 1.0
 */
@Slf4j
@Service
public class PlanHDeviceServiceImpl implements PlanHDeviceService {
    @Resource
    PlanHDeviceMapper planHDeviceMapper;
    @Resource
    private PlanService planService;
    @Resource
    private LoginDto loginDto;

    @Override

    public Long add(PlanHDevice type) {
        int state = planHDeviceMapper.insert(type);
        if (1 == state) {
            return type.getId();
        }
        return null;
    }

    @Override
    public boolean delete(Long id, Long validateId) {
        PlanHDevice planHDevice = planHDeviceMapper.selectById(id);
        if (validateId.equals(planHDevice.getWpiId())) {
            int type = planHDeviceMapper.deleteById(id);
            if (1 == type) {
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean update(PlanHDevice type) {
        int state = planHDeviceMapper.updateById(type);
        if (1 == state) {
            return true;
        }
        return false;
    }

    @Override
    public PlanHDevice selectById(Long id, Long validateId) {
        PlanHDevice planHDevice = planHDeviceMapper.selectById(id);
        if (validateId.equals(planHDevice.getWpiId())) {
            return planHDevice;
        }
        return null;
    }

    @Override
    public Page<PlanHDevice> list(PlanHDeviceDto dto) {
        return null;
    }

    @Override
    public LambdaQueryWrapper<PlanHDevice> fuzzyQuery(PlanHDeviceDto dto) {
        return null;
    }
}
